package com.ruoyi.dl.controller;

import java.util.List;
import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.ModelMap;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.dl.domain.DlOrdersCxlog;
import com.ruoyi.dl.service.IDlOrdersCxlogService;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 撤销订单记录Controller
 * 
 * @author ruoyi
 * @date 2021-01-09
 */
@Controller
@RequestMapping("/dl/cxlog")
public class DlOrdersCxlogController extends BaseController
{
    private String prefix = "dl/cxlog";

    @Autowired
    private IDlOrdersCxlogService dlOrdersCxlogService;

    @RequiresPermissions("dl:cxlog:view")
    @GetMapping()
    public String cxlog()
    {
        return prefix + "/cxlog";
    }

    /**
     * 查询撤销订单记录列表
     */
    @RequiresPermissions("dl:cxlog:list")
    @PostMapping("/list")
    @ResponseBody
    public TableDataInfo list(DlOrdersCxlog dlOrdersCxlog)
    {
        startPage();
        List<DlOrdersCxlog> list = dlOrdersCxlogService.selectDlOrdersCxlogList(dlOrdersCxlog);
        return getDataTable(list);
    }

    /**
     * 导出撤销订单记录列表
     */
    @RequiresPermissions("dl:cxlog:export")
    @Log(title = "撤销订单记录", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    @ResponseBody
    public AjaxResult export(DlOrdersCxlog dlOrdersCxlog)
    {
        List<DlOrdersCxlog> list = dlOrdersCxlogService.selectDlOrdersCxlogList(dlOrdersCxlog);
        ExcelUtil<DlOrdersCxlog> util = new ExcelUtil<DlOrdersCxlog>(DlOrdersCxlog.class);
        return util.exportExcel(list, "cxlog");
    }

    /**
     * 新增撤销订单记录
     */
    @GetMapping("/add")
    public String add()
    {
        return prefix + "/add";
    }

    /**
     * 新增保存撤销订单记录
     */
    @RequiresPermissions("dl:cxlog:add")
    @Log(title = "撤销订单记录", businessType = BusinessType.INSERT)
    @PostMapping("/add")
    @ResponseBody
    public AjaxResult addSave(DlOrdersCxlog dlOrdersCxlog)
    {
        return toAjax(dlOrdersCxlogService.insertDlOrdersCxlog(dlOrdersCxlog));
    }

    /**
     * 修改撤销订单记录
     */
    @GetMapping("/edit/{id}")
    public String edit(@PathVariable("id") Integer id, ModelMap mmap)
    {
        DlOrdersCxlog dlOrdersCxlog = dlOrdersCxlogService.selectDlOrdersCxlogById(id);
        mmap.put("dlOrdersCxlog", dlOrdersCxlog);
        return prefix + "/edit";
    }

    /**
     * 修改保存撤销订单记录
     */
    @RequiresPermissions("dl:cxlog:edit")
    @Log(title = "撤销订单记录", businessType = BusinessType.UPDATE)
    @PostMapping("/edit")
    @ResponseBody
    public AjaxResult editSave(DlOrdersCxlog dlOrdersCxlog)
    {
        return toAjax(dlOrdersCxlogService.updateDlOrdersCxlog(dlOrdersCxlog));
    }

    /**
     * 删除撤销订单记录
     */
    @RequiresPermissions("dl:cxlog:remove")
    @Log(title = "撤销订单记录", businessType = BusinessType.DELETE)
    @PostMapping( "/remove")
    @ResponseBody
    public AjaxResult remove(String ids)
    {
        return toAjax(dlOrdersCxlogService.deleteDlOrdersCxlogByIds(ids));
    }
    /**
     * 审核撤销订单记录
     */
    @PostMapping( "/updateshDlOrdersCxlogByIds")
    @ResponseBody
    public AjaxResult updateshDlOrdersCxlogByIds(String ids,String flag)
    {
        return toAjax(dlOrdersCxlogService.updateshDlOrdersCxlogByIds(ids,flag));
    }
}
